package show.me.the.money.config.app;

import java.util.HashMap;
import java.util.List;


import org.dom4j.Attribute;
import org.dom4j.Element;


public class Action{
	private Element define;
	private String id;
	private Module module;
	
	public Action(Element define){
		this.define = define;
		id = define.attributeValue("id");
	}
		
	public void setModule(Module m){
		module = m;
	}
	
	
	public String getFullId(){
		return module.getFullId() + "." + id;
	}
	
	public String getId(){
		return id;
	}
	
	@SuppressWarnings("unchecked")
	public HashMap<String,Object> data(){
		HashMap<String,Object> h = new HashMap<String,Object>();
		List<Attribute> attrs = define.attributes();
		for(Attribute attr : attrs){
			h.put(attr.getName(), attr.getText());
		}
		return h;
	}
	
}
